package com.mzy.datepackage.M2022.Apr.twFour;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author mzy
 * @Date 2022/4/26 17:25
 * @Version 1.0
 */
public class test3 {
    public static void main(String[] args) {
        Runnable runnable1 = new Runnable() {
            public void run() {
                System.out.println("Handsome 1");
            }
        };

        Runnable runnable2 = new Runnable() {
            public void run() {
                System.out.println("Handsome 2");
            }
        };


        ScheduledExecutorService service = Executors
                .newSingleThreadScheduledExecutor();

        /**
         *   参数2：首次执行延迟时间
         *   参数3：每次间隔执行时间
         */

        //靓仔1号
        service.scheduleAtFixedRate(runnable1, 5, 1, TimeUnit.SECONDS);
        //靓仔2号
        service.scheduleAtFixedRate(runnable2, 5, 1, TimeUnit.SECONDS);
    }
}
